import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

class WebViewPage extends StatefulWidget {
  Map arguements;

  WebViewPage(this.arguements, {Key? key}) : super(key: key);


  @override
  _WebViewPageState createState() => _WebViewPageState(arguements);
}

class _WebViewPageState extends State<WebViewPage> {
  Map arguements;
  _WebViewPageState(this.arguements); // Instance of WebView plugin
  final flutterWebViewPlugin = FlutterWebviewPlugin();

  @override
  void dispose() {
    // Every listener should be canceled, the same should be done with this stream.
    flutterWebViewPlugin.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // dynamic bean = ModalRoute.of(context)!.settings.arguments;
   String url = arguements["url"];
    LogUtil.e("webview url : $url");

    return WebviewScaffold(
      url: url,
      // mediaPlaybackRequiresUserGesture: false,
      appBar: AppBar(
        title: Text(arguements["title"]),
      ),
      // withZoom: true,
      // withLocalStorage: true,
      // hidden: true,
      initialChild: const Center(
        child: Text('Waiting.....'),
      ),
      // bottomNavigationBar: BottomAppBar(
      //   child: Row(
      //     children: [
      //       IconButton(
      //         icon: const Icon(Icons.arrow_back_ios),
      //         onPressed: () {
      //           flutterWebViewPlugin.goBack();
      //         },
      //       ),
      //       IconButton(
      //         icon: const Icon(Icons.arrow_forward_ios),
      //         onPressed: () {
      //           flutterWebViewPlugin.goForward();
      //         },
      //       ),
      //       IconButton(
      //         icon: const Icon(Icons.autorenew),
      //         onPressed: () {
      //           flutterWebViewPlugin.reload();
      //         },
      //       ),
      //     ],
      //   ),
      // ),
    );
  }
}
